--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_shikieiki_yamazanadou = General:new(extension, "hy_shikieiki_yamazanadou", "ten_k", 4, 4, General.Female)
    local convict = fk.CreateSkill {
        name = "convict",
    }
    convict:addEffect(fk.EventPhaseStart, {
        can_trigger = function(self, event, target, player)
            return player:hasSkill(convict.name) and player == target and player.phase == Player.Play and #player:getCardIds("h") > 0
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player)
            local room = player.room
            local ids = room:askToCards(player, {
                min_num = 1,
                max_num = 1,
                skill_name = convict.name,
                cancelable = false,
                prompt = "convict_prompt"
            })
            if type(ids) == "number" then
                ids = { ids }
            end
            local card = Fk:getCardById(ids[1])
            player:showCards({ card.id })
            room:setPlayerMark(player, "convict_prohibit-turn", card.id)
            room:setPlayerMark(player, "@convict_color", card:getColorString())
        end,
    })
    convict:addEffect(fk.CardShown, {
        can_refresh = function(self, event, target, player, data)
            return target == player and player:hasSkill(convict.name, true)
        end,
        on_refresh = function(self, event, target, player, data)
            local marks = player:getTableMark("@$convict_card")
            local room = player.room
            for _, id in ipairs(data.cardIds) do
                table.insertIfNeed(marks, id)
                room:setCardMark(Fk:getCardById(id), "@@convict-inhand", 1)
            end
            if #marks == 0 then
                marks = 0
            end
            player.room:setPlayerMark(player, "@$convict_card", marks)
        end,
    })
    convict:addEffect(fk.AfterCardsMove, {
        can_refresh = function(self, event, target, player, data)
            return #table.filter(data, function(move)
                return move.from == player
            end) > 0
        end,
        on_refresh = function(self, event, target, player, data)
            local marks = player:getTableMark("@$convict_card")
            local room = player.room
            for _, move in pairs(data) do
                if move.from == player then
                    for _, info in pairs(move.moveInfo) do
                        if info.fromArea == Card.PlayerHand then
                            table.removeOne(marks, info.cardId)
                            room:setCardMark(Fk:getCardById(info.cardId), "@@convict-inhand", 0)
                        end
                    end
                end
            end
            if #marks == 0 then
                marks = 0
            end
            player.room:setPlayerMark(player, "@$convict_card", marks)
        end,
    })
    convict:addEffect("prohibit", {
        prohibit_use = function(self, player, card)
            return player:hasSkill(self) and card and card.id == player:getMark("convict_prohibit-turn") and player:getMark("convict_prohibit-turn") ~= 0
        end,
        prohibit_response = function(self, player, card)
            return player:hasSkill(self) and card and card.id == player:getMark("convict_prohibit-turn") and player:getMark("convict_prohibit-turn") ~= 0
        end,
    })
    convict:addEffect(fk.CardUsing, {
        can_refresh = function(self, event, target, player, data)
            local room = Fk:currentRoom()
            if not player:hasSkill(convict.name) then
                return false
            end
            return target == player or table.any(room.alive_players, function(t)
                return t:getMark("convict_prohibit_other") ~= 0
            end)
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            if target == player then
                --本人使用牌：封牌
                for _, t in ipairs(room:getOtherPlayers(player)) do
                    room:setPlayerMark(t, "convict_prohibit_other", player:getMark("@$convict_card"))
                end
            else
                --他人使用牌：解封
                for _, t in ipairs(room.alive_players) do
                    room:setPlayerMark(t, "convict_prohibit_other", 0)
                end
            end
        end,
    })
    convict:addEffect(fk.CardUseFinished, {
        can_refresh = function(self, event, target, player, data)
            if not player:hasSkill(convict.name) then
                return false
            end
            return target == player
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            if data.card.trueName == "nullification" then
                --本人使用无懈结束：封牌
                for _, t in ipairs(room:getOtherPlayers(player)) do
                    room:setPlayerMark(t, "convict_prohibit_other", player:getMark("@$convict_card"))
                end
            else
                --本人使用其他牌结束：解封
                for _, t in ipairs(room.alive_players) do
                    room:setPlayerMark(t, "convict_prohibit_other", 0)
                end
            end
        end,
    })
    convict:addEffect("prohibit", {
        prohibit_use = function(self, player, card)
            if Fk.currentResponsePattern == nil or Exppattern:Parse(Fk.currentResponsePattern):match(Fk:cloneCard("peach")) then
                return false
            end
            if not card:isVirtual() and not table.contains(player.player_cards[Player.Hand], card.id) then
                return false
            end
            if card:isVirtual() and (#card.subcards == 0 or table.any(card.subcards, function(id)
                    return not table.contains(player.player_cards[Player.Hand], id)
                end)) then
                return false
            end
            if player:getMark("convict_prohibit_other") ~= 0 then
                for _, c in ipairs(table.map(player:getMark("convict_prohibit_other"), function(id)
                    return Fk:getCardById(id)
                end)) do
                    if card.color == c.color then
                        return true
                    end
                end
            end
        end,
        prohibit_response = function(self, player, card)
            if Fk.currentResponsePattern == nil then
                return false
            end
            if not card:isVirtual() and not table.contains(player.player_cards[Player.Hand], card.id) then
                return false
            end
            if card:isVirtual() and (#card.subcards == 0 or table.any(card.subcards, function(id)
                    return not table.contains(player.player_cards[Player.Hand], id)
                end)) then
                return false
            end
            if player:getMark("convict_prohibit_other") ~= 0 then
                for _, c in ipairs(table.map(player:getMark("convict_prohibit_other"), function(id)
                    return Fk:getCardById(id)
                end)) do
                    if card.color == c.color then
                        return true
                    end
                end
            end
        end,
    })
    local judgement = fk.CreateSkill {
        name = "judgement",
    }
    judgement:addEffect(fk.TargetSpecified, {
        anim_type = "offensive",
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(judgement.name) and player == target and player.phase == Player.Play and data.firstTarget and table.any(data:getAllTargets(), function(t)
                return t ~= player and #t:getCardIds("h") > 0
            end) and player:getMark("judgement_disable-turn") == 0 and player:getMark("@convict_color") ~= 0
        end,
        on_cost = function(self, event, target, player, data)
            event:setCostData(self, nil)
            local room = player.room
            local targets = table.filter(data:getAllTargets(), function(t)
                return t ~= player and #t:getCardIds("h") > 0
            end)
            if #targets > 1 then
                local result = room:askToChoosePlayers(player, {
                    targets = targets,
                    min_num = 1,
                    max_num = 1,
                    prompt = "judgement_prompt",
                    skill_name = judgement.name
                })
                if #result > 0 then
                    event:setCostData(self, result[1].id)
                end
            elseif #targets == 1 then
                if room:askToSkillInvoke(player, {
                        skill_name = judgement.name,
                        prompt = "judgement_prompt_single::" .. targets[1].id
                    }) then
                    event:setCostData(self, targets[1].id)
                end
            end
            return event:getCostData(self) ~= nil
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local skillTarget = room:getPlayerById(event:getCostData(self))
            local card = Fk:getCardById(room:askToChooseCard(player, {
                target = skillTarget,
                flag = "h",
                skill_name = judgement.name
            }))
            room:showCards(card)
            local color = player:getMark("@convict_color")
            if card:getColorString() == color then
                if room:askToSkillInvoke(player, {
                        skill_name = judgement.name,
                        prompt = "judgement_prompt_same"
                    }) then
                    room:setPlayerMark(player, "judgement_disable-turn", 1)
                    room:obtainCard(player, card, true, fk.ReasonPrey)
                    room:drawCards(player, 1, judgement.name)
                end
            else
                if room:askToSkillInvoke(player, {
                        skill_name = judgement.name,
                        prompt = "judgement_prompt_diff::" .. event:getCostData(self)
                    }) then
                    room:setPlayerMark(player, "judgement_disable-turn", 1)
                    local cardId = room:askToChooseCard(player, {
                        target = skillTarget,
                        flag = "he",
                        skill_name = judgement.name
                    })
                    room:throwCard(cardId, judgement.name, skillTarget, player)
                    room:damage({
                        from = player,
                        to = skillTarget,
                        damage = 1,
                        damageType = fk.ThunderDamage,
                        skillName = judgement.name,
                    })
                end
            end
        end,
    })
    extension:loadSkillSkels { convict, judgement }
    hy_shikieiki_yamazanadou:addSkill("convict")
    hy_shikieiki_yamazanadou:addSkill("judgement")
    Fk:loadTranslationTable {
        ["hy_shikieiki_yamazanadou"] = "四季映姬",
        ["#hy_shikieiki_yamazanadou"] = "事实无情",
        ["illustrator:hy_shikieiki_yamazanadou"] = "つね",
        ["designer:hy_shikieiki_yamazanadou"] = "黑曜人形",
        ["cv:hy_shikieiki_yamazanadou"] = "",

        ["convict"] = "断罪",
        [":convict"] = "出牌阶段开始时，你展示一张手牌，记录此牌颜色并清除之前的记录，然后无法使用或打出此牌直到本回合结束。其他角色无法用与你展示过的手牌相同颜色的手牌响应你使用的牌。",
        ["convict_prompt"] = "断罪：你须展示一张手牌",
        ["@convict_color"] = "断罪",
        ["@$convict_card"] = "断罪",
        ["@@convict-inhand"] = "断罪",

        ["judgement"] = "审判",
        [":judgement"] = "出牌阶段，在你使用牌指定其他角色为目标后，你可以展示其中一个目标一张手牌，若此牌颜色与“断罪”记录的颜色相同/不同，你可以获得此牌并摸一张牌/弃置其一张牌并对其造成1点雷电伤害，然后“审判”本回合失效。",
        ["judgement_prompt"] = "审判：你可以展示其中一个目标一张手牌",
        ["judgement_prompt_single"] = "审判：你可以展示%dest一张手牌",
        ["judgement_prompt_same"] = "审判：你可以获得此牌并摸一张牌",
        ["judgement_prompt_diff"] = "审判：你可以弃置%dest一张牌并对其造成1点雷电伤害",
    }
end
